import { Type } from "class-transformer";
import { UniverseGroup } from "./UniverseGroup";

/**
 * 物品大类
 */
export class UniverseCategory {
  // 类别 ID 整数
  id!: number;

  // 组数组，可包含最多 1000 个整数
  @Type(() => UniverseGroup)
  children: UniverseGroup[] = [];

  // 名称字符串
  name!: string;

  // 是否已发布布尔值
  published!: boolean;

  static fromCategory(category: any) {
    const universeCategory = new UniverseCategory();
    universeCategory.name = category.name;
    universeCategory.id = category.category_id;
    universeCategory.published = category.published;
    return universeCategory;
  }
}
